home *** CD-ROM | disk | FTP | other *** search
/ mail.altrad.com / 2015.02.mail.altrad.com.tar / mail.altrad.com / TEST / office german / PROPLUS.WW / PROPLSWW.CAB / as80.xsl.5DF9D670_534C_4AB2_B0C6_FF0B0C448C29 < prev    next >
Extensible Markup Language  |  2006-10-26  |  17KB  |  387 lines

  1. <?xml version="1.0"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" version="1.0" xmlns:mssqlcrt="urn:sql-microsoft-com:sqlcrt" xmlns:mssqldbg="urn:sql-microsoft-com:sqldbg">
  3.     <xsl:output method="xml" indent="yes"/>
  4.  
  5.     <!-- This ALWAYS GENERATED file contains the definitions for the cartridges
  6.                  Microsoft Cartridge Interfaces (Analysis Services 2005)
  7.                  (C) Copyright 1988 - 2003 By Microsoft Corporation.      -->
  8.  
  9.     <!-- Microsoft Analysis Server 2000 (Shiloh) pluggable cartridge      -->
  10.  
  11.     <!-- Area of STANDARD parametrizations: these are externally passed   -->
  12.     <xsl:param name="in_CanUseParams">no</xsl:param>
  13.     <xsl:param name="in_IdentStartQuotingCharacter">[</xsl:param>
  14.     <xsl:param name="in_IdentEndQuotingCharacter">]</xsl:param>
  15.     <xsl:param name="in_StringStartQuotingCharacter">'</xsl:param>
  16.     <xsl:param name="in_StringEndQuotingCharacter">'</xsl:param>
  17.     
  18.     <!-- Area of CORE parametrizations: These are externally checked      -->
  19.     <mssqlcrt:provider type="prefix">OLAP server</mssqlcrt:provider>
  20.  
  21.     <mssqlcrt:capabilities>
  22.         <mssqlcrt:supports-column-alias/>
  23.     </mssqlcrt:capabilities>
  24.  
  25.     <mssqlcrt:schema-classes>
  26.         <mssqlcrt:schema-class>
  27.             <mssqlcrt:managed-provider>System.Data.OleDb</mssqlcrt:managed-provider>
  28.             <mssqlcrt:type>Microsoft.DataWarehouse.Design.OleDbSchema, Microsoft.DataWarehouse</mssqlcrt:type>
  29.             <mssqlcrt:query-designer>
  30.                 <mssqlcrt:type>Microsoft.DataWarehouse.Controls.OleDbQueryDesigner, Microsoft.DataWarehouse</mssqlcrt:type>
  31.             </mssqlcrt:query-designer>
  32.         </mssqlcrt:schema-class>
  33.         <mssqlcrt:schema-class>
  34.             <mssqlcrt:managed-provider>System.Data.Odbc</mssqlcrt:managed-provider>
  35.             <mssqlcrt:type>Microsoft.DataWarehouse.Design.OdbcSchema, Microsoft.DataWarehouse</mssqlcrt:type>
  36.         </mssqlcrt:schema-class>
  37.     </mssqlcrt:schema-classes>
  38.  
  39.     <!-- Area of internal parametrizations                                -->
  40.     <!-- overrideOfUseParams:
  41.              yes      = use always parametric queries
  42.              no       = never use parametric queries
  43.              nosubsel = use as yes, but not on subselects
  44.              auto     = use the value of in_CanUseParams to determine     -->
  45.     <xsl:variable name="overrideOfUseParams">auto</xsl:variable>
  46.     <!-- shouldProduceDebug:
  47.              yes      = produce debug information
  48.              no       = do not produce debug information                  -->
  49.     <xsl:variable name="shouldProduceDebug">yes</xsl:variable>
  50.  
  51.     <!-- Area of global variables initializations                         -->
  52.     <xsl:variable name="UseParams">
  53.         <xsl:choose>
  54.             <xsl:when test="normalize-space($overrideOfUseParams) = 'yes' or (normalize-space($overrideOfUseParams) = 'auto' and normalize-space($in_CanUseParams)='yes')">yes</xsl:when>
  55.             <xsl:when test="normalize-space($overrideOfUseParams) = 'nosubsel'">nosubsel</xsl:when>
  56.             <xsl:otherwise>no</xsl:otherwise>
  57.         </xsl:choose>
  58.     </xsl:variable>
  59.     <xsl:variable name="ProduceDebug" select="$shouldProduceDebug"/>
  60.     <xsl:variable name="IdentifierStartQuotingCharacter" select="normalize-space($in_IdentStartQuotingCharacter)"/>
  61.     <xsl:variable name="IdentifierEndQuotingCharacter" select="normalize-space($in_IdentEndQuotingCharacter)"/>
  62.     <xsl:variable name="StringStartQuotingCharacter" select="normalize-space($in_StringStartQuotingCharacter)"/>
  63.     <xsl:variable name="StringEndQuotingCharacter" select="normalize-space($in_StringEndQuotingCharacter)"/>
  64.  
  65.     <!-- Generated statement packaging                                    -->
  66.     <xsl:template match="/">
  67.         <xsl:element name="Statement">
  68.  
  69.             <!-- Generate query                                           -->
  70.             <xsl:element name="Text">
  71.                 <xsl:apply-templates select="./Statement/*[1]"/>
  72.             </xsl:element>
  73.  
  74.             <!-- Generate parameters                                      -->
  75.             <xsl:if test="count(./Statement/Parameters/Parameter)!=0 and ((normalize-space($UseParams)='yes') or (normalize-space($UseParams)='nosubsel'))">
  76.                 <xsl:element name="Parameters">
  77.                     <xsl:choose>
  78.                         <xsl:when test="/Statement/*[1]//Parameter/@ParamName">
  79.                             <xsl:for-each select="./Statement/Parameters/Parameter">
  80.                                 <xsl:element name="Parameter">
  81.                                     <xsl:attribute name="ref">
  82.                                         <xsl:value-of select="./@id"/>
  83.                                     </xsl:attribute>
  84.                                 </xsl:element>
  85.                             </xsl:for-each>
  86.                         </xsl:when>
  87.                         <xsl:otherwise>
  88.                             <xsl:for-each select="./Statement/*[1]//Parameter">
  89.                                 <xsl:element name="Parameter">
  90.                                     <xsl:attribute name="ref">
  91.                                         <xsl:value-of select="./@ref"/>
  92.                                     </xsl:attribute>
  93.                                 </xsl:element>
  94.                             </xsl:for-each>
  95.                         </xsl:otherwise>
  96.                     </xsl:choose>
  97.                 </xsl:element>
  98.             </xsl:if>
  99.  
  100.             <!-- Generate debug info                                      -->
  101.             <xsl:if test="$ProduceDebug='yes'">
  102.                 <xsl:element name="mssqldbg:DebugInfo">
  103.                     <xsl:element name="mssqldbg:GenerateParametricInfo">
  104.                         <xsl:attribute name="mssqldbg:Value">
  105.                             <xsl:value-of select="$UseParams"/>
  106.                         </xsl:attribute>
  107.                         <xsl:element name="mssqldbg:External">
  108.                             <xsl:value-of select="$in_CanUseParams"/>
  109.                         </xsl:element>
  110.                         <xsl:element name="mssqldbg:Internal">
  111.                             <xsl:value-of select="$overrideOfUseParams"/>
  112.                         </xsl:element>
  113.                     </xsl:element>
  114.                 </xsl:element>
  115.             </xsl:if>
  116.  
  117.         </xsl:element>
  118.     </xsl:template>
  119.  
  120.     <!-- Select statement                                                 -->
  121.     <xsl:template match="Select">
  122.         SELECT <xsl:apply-templates select="./Distinct"/>
  123.             <xsl:apply-templates select="./ColumnExpressions"/>
  124.             <xsl:apply-templates select="./Sources"/>
  125.             <xsl:apply-templates select="./Where"/>
  126.             <xsl:apply-templates select="./GroupBy"/>
  127.             <xsl:apply-templates select="./OrderBy"/>
  128.     </xsl:template>
  129.  
  130.     <xsl:template match="Distinct">
  131.         DISTINCT
  132.     </xsl:template>
  133.  
  134.     <xsl:template match="As">
  135.         <xsl:apply-templates select="./*[1]"/> AS <xsl:apply-templates select="./*[2]"/>
  136.     </xsl:template>
  137.  
  138.     <xsl:template match="Sources">
  139.         FROM <xsl:call-template name="print-children-list"/>
  140.     </xsl:template>
  141.  
  142.     <xsl:template match="GroupBy">
  143.         GROUP BY <xsl:call-template name="print-children-list"/>
  144.     </xsl:template>
  145.  
  146.     <xsl:template match="OrderBy">
  147.         ORDER BY <xsl:call-template name="print-children-list"/>
  148.     </xsl:template>
  149.  
  150.     <xsl:template match="Where">
  151.         WHERE <xsl:apply-templates select="./*"/>
  152.     </xsl:template>
  153.  
  154.     <xsl:template match="ColumnExpressions">
  155.         <xsl:call-template name="print-children-list"/>
  156.     </xsl:template>
  157.  
  158.     <xsl:template match="SQLColumn">
  159.         <xsl:variable name="table">
  160.             <xsl:if test="name(..)!='Count' or name(./Column/*[1]) != 'Asterisk'"><xsl:apply-templates select="./Table"/></xsl:if>
  161.         </xsl:variable>
  162.         <xsl:variable name="column">
  163.             <xsl:apply-templates select="./Column"/>
  164.         </xsl:variable>
  165.         <xsl:choose>
  166.             <xsl:when test="$table = ''">
  167.                 <xsl:value-of select="$column"/>
  168.             </xsl:when>
  169.             <xsl:otherwise>
  170.                 <xsl:value-of select="concat($table,'.', $column)"/>
  171.             </xsl:otherwise>
  172.         </xsl:choose>
  173.     </xsl:template>
  174.  
  175.     <xsl:template match="Table">
  176.         <xsl:call-template name="build-quoted-schema-object"/>
  177.     </xsl:template>
  178.  
  179.     <xsl:template match="Column">
  180.         <xsl:apply-templates select="./Asterisk"/>
  181.         <xsl:apply-templates select="./Name"/>
  182.     </xsl:template>
  183.  
  184.     <xsl:template match="Table/Name|View/Name|Index/Name|Column/Name|Database/Name|Schema">
  185.         <xsl:call-template name="quote-identifier"/>
  186.     </xsl:template>
  187.  
  188.     <xsl:template match="OpaqueExpression">
  189.         <xsl:if test="name(..) = 'As' and name(../..) = 'Sources'">
  190.             (
  191.         </xsl:if>
  192.         <xsl:value-of select="."/>
  193.         <xsl:if test="name(..) = 'As' and name(../..) = 'Sources'">
  194.             )
  195.         </xsl:if>
  196.     </xsl:template>
  197.  
  198.     <xsl:template match="OrderExpression">
  199.         <xsl:apply-templates select="./*[1]"/>
  200.         <xsl:apply-templates select="./Asc"/>
  201.         <xsl:apply-templates select="./Desc"/>
  202.     </xsl:template>
  203.  
  204.     <xsl:template match="Asc">
  205.         ASC
  206.     </xsl:template>
  207.  
  208.     <xsl:template match="Desc">
  209.         DESC
  210.     </xsl:template>
  211.  
  212.     <!-- Asterisk                                                         -->
  213.     <xsl:template match="Asterisk">*</xsl:template>
  214.  
  215.     <!-- Count/Min/Max/Sum                                                -->
  216.     <xsl:template match="Count|Min|Max|Sum">
  217.         <xsl:variable name="function">
  218.             <xsl:choose>
  219.                 <xsl:when test="name()='Count'"> COUNT </xsl:when>
  220.                 <xsl:when test="name()='Min'"> MIN </xsl:when>
  221.                 <xsl:when test="name()='Max'"> MAX </xsl:when>
  222.                 <xsl:when test="name()='Sum'"> SUM </xsl:when>
  223.             </xsl:choose>
  224.         </xsl:variable>
  225.         <xsl:value-of select="$function"/>( <xsl:apply-templates select="./*[1]"/> )
  226.     </xsl:template>
  227.  
  228.     <!-- Binary expressions                                               -->
  229.     <!-- Equal/NotEqual/Greater/GreaterOrEqual/Less/LessOrEqual/In/And/Or/Plus/Minus/Divide/Multiply
  230.          expressions                                                      -->
  231.     <xsl:template match="Equal|NotEqual|Greater|GreaterOrEqual|Less|LessOrEqual|In|And|Or|Plus|Minus|Divide|Multiply">
  232.         <xsl:variable name="operator">
  233.             <xsl:choose>
  234.                 <xsl:when test="name()='Equal'">            =        </xsl:when>
  235.                 <xsl:when test="name()='NotEqual'">            <>    </xsl:when>
  236.                 <xsl:when test="name()='Greater'">            >        </xsl:when>
  237.                 <xsl:when test="name()='GreaterOrEqual'">    >=        </xsl:when>
  238.                 <xsl:when test="name()='Less'">                <    </xsl:when>
  239.                 <xsl:when test="name()='LessOrEqual'">        <=    </xsl:when>
  240.                 <xsl:when test="name()='In'">                IN        </xsl:when>
  241.                 <xsl:when test="name()='And'">                AND        </xsl:when>
  242.                 <xsl:when test="name()='Or'">                OR        </xsl:when>
  243.                 <xsl:when test="name()='Plus'">                +        </xsl:when>
  244.                 <xsl:when test="name()='Minus'">            -        </xsl:when>
  245.                 <xsl:when test="name()='Divide'">            /        </xsl:when>
  246.                 <xsl:when test="name()='Multiply'">            *        </xsl:when>
  247.             </xsl:choose>
  248.         </xsl:variable>
  249.         (
  250.             <xsl:call-template name="print-children-list">
  251.                 <xsl:with-param name="operator" select="$operator"/>
  252.             </xsl:call-template>
  253.         )
  254.     </xsl:template>
  255.     
  256.     <!-- By default don't do anything                                     -->
  257.     <xsl:template match="*">
  258.     </xsl:template>
  259.  
  260.     <!-- Print a schema object                                               -->
  261.     <xsl:template name="build-quoted-schema-object"> 
  262.         <xsl:param name="schema-object-node" select="."/>
  263.  
  264.         <xsl:variable name="schema">
  265.             <xsl:apply-templates select="$schema-object-node/Schema"/>
  266.         </xsl:variable>
  267.         <xsl:variable name="table">
  268.             <xsl:apply-templates select="$schema-object-node/Name"/>
  269.         </xsl:variable>
  270.         <xsl:choose>
  271.             <xsl:when test="$schema = ''">
  272.                 <xsl:value-of select="$table"/>
  273.             </xsl:when>
  274.             <xsl:otherwise>
  275.                 <xsl:value-of select="concat($schema,'.', $table)"/>
  276.             </xsl:otherwise>
  277.         </xsl:choose>
  278.     </xsl:template>
  279.  
  280.     <!-- Convert an identifier to the OLEDB quotation form                -->
  281.     <xsl:template name="quote-identifier"> 
  282.         <xsl:param name="identifier" select="."/>
  283.  
  284.         <xsl:value-of select="$IdentifierStartQuotingCharacter"/>
  285.         <xsl:call-template name="normalize-entity-aux">
  286.             <xsl:with-param name="entity" select="$identifier"/>
  287.             <xsl:with-param name="end-quoting-char" select="$IdentifierEndQuotingCharacter"/>
  288.         </xsl:call-template>
  289.         <xsl:value-of select="$IdentifierEndQuotingCharacter"/>
  290.     </xsl:template>
  291.  
  292.     <!-- Convert a string to the string quotation form                    -->
  293.     <xsl:template name="quote-string"> 
  294.         <xsl:param name="string" select="."/>
  295.  
  296.         <xsl:value-of select="$StringStartQuotingCharacter"/>
  297.         <xsl:call-template name="normalize-entity-aux">
  298.             <xsl:with-param name="entity" select="$string"/>
  299.             <xsl:with-param name="end-quoting-char" select="$StringEndQuotingCharacter"/>
  300.         </xsl:call-template>
  301.         <xsl:value-of select="$StringEndQuotingCharacter"/>
  302.     </xsl:template>
  303.  
  304.     <!-- Convert an entity to the quotation form (recursive, aux)  by
  305.          duplicating the end quoting character                            -->
  306.     <xsl:template name="normalize-entity-aux"> 
  307.         <xsl:param name="entity"/>
  308.         <xsl:param name="end-quoting-char"/>
  309.  
  310.         <xsl:choose>
  311.             <xsl:when test="contains($entity, $end-quoting-char)">
  312.                 <xsl:value-of select="substring-before($entity, $end-quoting-char)"/>
  313.                 <xsl:value-of select="$end-quoting-char"/>
  314.                 <xsl:value-of select="$end-quoting-char"/>
  315.                 <xsl:call-template name="normalize-entity-aux">
  316.                     <xsl:with-param name="entity" select="substring-after($entity, $end-quoting-char)"/>
  317.                     <xsl:with-param name="end-quoting-char" select="$end-quoting-char"/>
  318.                 </xsl:call-template>
  319.             </xsl:when>
  320.             <xsl:otherwise>
  321.                 <xsl:value-of select="$entity"/>
  322.             </xsl:otherwise>
  323.         </xsl:choose>
  324.     </xsl:template>
  325.  
  326.     <!-- Print the children list                                          -->
  327.     <xsl:template name="print-children-list">
  328.         <xsl:param name="operator" select="','"/>
  329.         
  330.         <xsl:call-template name="print-list">
  331.             <xsl:with-param name="value-node" select="./*"/>
  332.             <xsl:with-param name="operator" select="$operator"/>
  333.         </xsl:call-template>
  334.     </xsl:template>
  335.  
  336.     <!-- Print a list                                                     -->
  337.     <xsl:template name="print-list">
  338.         <xsl:param name="operator" select="','"/>
  339.         <xsl:param name="value-node" select="."/>
  340.  
  341.         <xsl:for-each select="$value-node">
  342.             <xsl:apply-templates select="."/>
  343.             <xsl:if test="position()!=last()">
  344.                 <xsl:value-of select="$operator"/>
  345.             </xsl:if>
  346.         </xsl:for-each>
  347.     </xsl:template>
  348.  
  349.     <!-- Get the value of a parameter ref for the query                   -->
  350.     <xsl:template name="print-non-parametric-parameter-ref">
  351.         <xsl:param name="parameter-reference"/>
  352.  
  353.         <xsl:variable name="reference"><xsl:value-of select="$parameter-reference/@ref"/></xsl:variable>
  354.         <xsl:call-template name="print-non-parametric-parameter">
  355.             <xsl:with-param name="parameter" select="/Statement/Parameters/Parameter[@id=$reference]"/>
  356.         </xsl:call-template>
  357.     </xsl:template>
  358.  
  359.     <!-- Get the value of a parameter ref for the query                   -->
  360.     <xsl:template name="print-non-parametric-parameter">
  361.         <xsl:param name="parameter"/>
  362.  
  363.         <xsl:variable name="db-type"><xsl:value-of select="$parameter/@DBTYPE"/></xsl:variable>
  364.         <xsl:variable name="value"><xsl:value-of select="$parameter/text()"/></xsl:variable>
  365.         <xsl:choose>
  366.             <xsl:when test="$db-type = 'DBTYPE_BSTR'"><xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template></xsl:when>
  367.             <xsl:when test="$db-type = 'DBTYPE_WSTR'"><xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template></xsl:when>
  368.             <xsl:when test="$db-type = 'DBTYPE_STR'"><xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template></xsl:when>
  369.             <xsl:when test="$db-type = 'DBTYPE_BOOL'">CAST( <xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template> AS bit)</xsl:when>
  370.             <xsl:when test="$db-type = 'DBTYPE_I1'"><xsl:value-of select="$value"/></xsl:when>
  371.             <xsl:when test="$db-type = 'DBTYPE_I2'"><xsl:value-of select="$value"/></xsl:when>
  372.             <xsl:when test="$db-type = 'DBTYPE_I4'"><xsl:value-of select="$value"/></xsl:when>
  373.             <xsl:when test="$db-type = 'DBTYPE_I8'"><xsl:value-of select="$value"/></xsl:when>
  374.             <xsl:when test="$db-type = 'DBTYPE_UI1'"><xsl:value-of select="$value"/></xsl:when>
  375.             <xsl:when test="$db-type = 'DBTYPE_UI2'"><xsl:value-of select="$value"/></xsl:when>
  376.             <xsl:when test="$db-type = 'DBTYPE_UI4'"><xsl:value-of select="$value"/></xsl:when>
  377.             <xsl:when test="$db-type = 'DBTYPE_UI8'"><xsl:value-of select="$value"/></xsl:when>
  378.             <xsl:when test="$db-type = 'DBTYPE_R4'"><xsl:value-of select="$value"/></xsl:when>
  379.             <xsl:when test="$db-type = 'DBTYPE_R8'"><xsl:value-of select="$value"/></xsl:when>
  380.             <xsl:when test="$db-type = 'DBTYPE_DATE'">CAST( <xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template> AS datetime)</xsl:when>
  381.             <xsl:when test="$db-type = 'DBTYPE_DBTIMESTAMP'">CAST( <xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template> AS datetime)</xsl:when>
  382.             <xsl:when test="$db-type = 'DBTYPE_CY'">CAST( <xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template> AS money)</xsl:when>
  383.             <xsl:when test="$db-type = 'DBTYPE_VARIANT'"><xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template></xsl:when>
  384.         </xsl:choose>
  385.     </xsl:template>
  386. </xsl:stylesheet>
  387.